let rec power  x n = match n with
  	0 -> 1
  	|n  when n<0 -> failwith "Il faut un n positif"
  	|_ -> x * power x (n-1);;
	
let rec application p x = match p with
  []-> 0
  |(l1,l2)::l -> l1  * power x l2 + application l x;;
  
application [(2,2);(2,3);(4,4)] 2;;

  let rec add l1 l2 = match l1 with
  []-> l2
  |(e1,e2)::l -> match l2 with
      []-> l1
      |(x,n)::l3 -> if n == e2 then ((e1+x),n):: add l l3
					else (e1,e2)::(x,n):: add l l3;;
	
add [(1,2);(2,6);(7,8);(2,12)] [(1,4);(3,6);(1,9)];;
				
let rec soustract l1 l2 = match l1 with
  []-> l2
  |(e1,e2)::l -> match l2 with
      []-> l1
      |(x,n)::l3 -> if n == e2 then ((e1-x),n):: soustract l l3
					else (e1,e2)::(-x,n):: soustract l l3;;

soustract [(1,2);(2,6);(7,8);(2,12)] [(1,4);(3,6);(1,9)];;
					
let rec deriv l = match l with
    []-> []
  |(x,n)::l1 -> ((n*x),(n-1))::deriv l1;;
  
deriv [(2,2);(2,3);(4,4)];;
